<style type="text/css">
    .center{text-align:center}
</style>
<body>
<div class="bjy-admin-nav">
    <i class="fa fa-home"></i> 首页
    &gt;
    后台管理
    &gt;
    添加门店用户
</div>
<ul id="myTab" class="nav nav-tabs">
    <li>
        <a href="<{:url('auth_user_list')}>">门店用户列表</a>
    </li>
    <li class="active">
        <a href="javascript:;">添加门店用户</a>
    </li>
</ul>
<form class="form-inline">
    <table class="table table-striped table-bordered table-hover table-condensed">
        <tr>
            <th style="width:100px;" class="center">权限组：</th>
            <td>
                <{volist name="group" id="vo"}>
                <{if condition="$vo.id eq 2"}>
                    <label for="<{$vo.id}>">
                        <{$vo.title}>
                        <input class="xb-icheck" type="radio" name="group_id" value="<{$vo.id}>" id="<{$vo.id}>" checked>
                        &emsp;
                    </label>
                <{else /}>
                    <label for="<{$vo.id}>">
                        <{$vo.title}>
                        <input class="xb-icheck" type="radio" name="group_id" value="<{$vo.id}>" id="<{$vo.id}>">
                        &emsp;
                    </label>
                <{/if}>
                    
                <{/volist}>
            </td>
        </tr>
        <tr>
            <th class="center">用户名：</th>
            <td>
                <input class="form-control" type="text" name="username" placeholder="请填写用户名" maxlength="20">
            </td>
        </tr>
        <tr>
            <th class="center">手机号：</th>
            <td>
                <input class="form-control" type="text" name="phone" placeholder="请填写手机号" maxlength="15">
            </td>
        </tr>
        <tr>
            <th class="center">邮箱：</th>
            <td>
                <input class="form-control" type="text" name="email" placeholder="请填写邮箱" maxlength="30">
            </td>
        </tr>
        <tr>
            <th class="center">初始密码：</th>
            <td>
                <input class="form-control" type="text" name="password" placeholder="请填写初始密码" maxlength="20">
            </td>
        </tr>
        <tr>
            <th></th>
            <td>
                <input class="btn btn-success submit" type="button" value="下一步">
            </td>
        </tr>
    </table>
</form>
</body>
<script type="text/javascript">
    $("input[name='username']").focus(function(){
        $(this).next('span').remove();
        $("<span> &nbsp;&nbsp;请输入正确的用户名</span>").css('color','#666').insertAfter($(this));
    }).blur(function(){
        s=$(this);
        s.next('span').remove();
        var username = s.val();
        if(username.match(/^\w{4,10}$/)==null){
            $("<span> &nbsp;&nbsp;请输入4-10位任意的数字字母下划线</span>").css('color','red').insertAfter(s);
                flag=false;//阻止提交
        }else{
            flag = true;
        }
    })
    $('.submit').click(function(){
        var allright = true;
        $('input[name]').each(function(k,v){
            if($.trim($(v).val())==''){
                alert($(v).attr('placeholder'));
                allright = false;
                return false;
            }
        })

        if(!allright) return false;

        if($("input[name='group_id']:checked").val() == undefined){
            alert('请选择用户组');
            return false;
        }
        var formdata = $('input[name]').serialize();
        $.post('',formdata,function(data){
            if(data.code){
                // alert(data.msg);
                window.location.href="<{:url('stores/storesAdd?href=1')}>";
            }else{
                alert(data.msg);
            }
        },'json');
    });
</script>